package common.utils
{
	import mx.formatters.DateFormatter;
	
	public class DateManager
	{
		public function DateManager()
		{
		}

		public static function GetTodayString():String{
			var formatter:DateFormatter = new DateFormatter();
			formatter.formatString = "YYYY-MM-DD";
			return formatter.format(new Date());
		}

		public static function GetNowString():String{
			var formatter:DateFormatter = new DateFormatter();
			formatter.formatString = "YYYY-MM-DD HH:NN:SS";
			return formatter.format(new Date());
		}
				
		public static function ParseDate(stDate:String):Date{
			if (stDate.length < 10)
				return new Date();
				
			stDate = stDate.substr(0, 10);
			var arFields:Array = stDate.split("-");
			if (arFields.length < 3){
				arFields = stDate.split("/");			
				if (arFields.length < 3)
					return new Date(); 
			}

			var iYear:Number = arFields[0];
			var iMonth:Number = arFields[1];
			var iDay:Number = arFields[2];
			
			return new Date(iYear, iMonth-1, iDay);
		}
	}
}